/*******************************************************************************
* This file declares all the public global variables.
*
* Author: Kong Wai Weng @ Cytron Technologies Sdn. Bhd.
*******************************************************************************/



#include "variables.h"



/*******************************************************************************
* PUBLIC GLOBAL VARIABLES                                                      *
*******************************************************************************/

// System congiguration.
volatile struct SYSTEM_CONFIG xSystemConfig = {0};

// System state.
volatile struct SYSTEM_STATE xSystemState = {0};

// System error.
volatile struct SYSTEM_ERROR xSystemError = {0};

// Stack watermark.
volatile struct STACK_WATER_MARK xStackWaterMark = {0};



// Mutex to indicate that the I2C is being access.
volatile xSemaphoreHandle mutexI2cBusy1 = 0;
volatile xSemaphoreHandle mutexI2cBusy2 = 0;

// Mutex to indicate that the serial flash is being access.
volatile xSemaphoreHandle mutexSerialFlashBusy = 0;



/*******************************************************************************
* PUBLIC FUNCTION: vInitVar
*
* PARAMETERS:
* ~ void
*
* RETURN:
* ~ void
*
* DESCRIPTIONS:
* Initialize the public global variables.
*
*******************************************************************************/
void vInitVar(void)
{	
	// Create Mutex.
	mutexI2cBusy1 = xSemaphoreCreateMutex();
	mutexI2cBusy2 = xSemaphoreCreateMutex();
	mutexSerialFlashBusy = xSemaphoreCreateMutex();
	
	
	
	// Load the system config into RAM.
	vLoadFlashData();
}	
